<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/5/31 0031
 * Time: 上午 9:22
 */

header("Content-type:text/html;charset=utf-8");
header("Access-Control-Allow-Origin:*");


//print_r($_POST);

if (!empty($_POST) && $_POST["uname"] != null && $_POST["upwd"] != null){

    $uname = $_POST["uname"];
    $upwd = $_POST["upwd"];

    //连接数据库;
    $connection = new mysqli("127.0.0.1","root","","mytps138");

    mysqli_query($connection,"set names utf8");

//    print_r($connection->connect_error);//  成功
    //sql语句;
    $sql = 'INSERT INTO userinfo (uemail,upwd) VALUE ("'.$uname.'","'.$upwd.'")';

    $res = $connection->query($sql);

    if($res){
        $arr = array("status" => 1);
        print_r(json_encode($arr));
    }else{
        $arr = array("status"=>2);
        print_r(json_encode($arr));
    }
}

$connection->close();


